<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增项目信息')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-project-add">
            <input name="geocode" type="hidden" th:value="${geocode}">
            <div class="form-group">    
                <label class="col-sm-3 control-label"><span style="color: red; ">*</span>项目名称：</label>
                <div class="col-sm-8">
                    <input name="projectName" id="projectName" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">项目类型：</label>
                <div class="col-sm-8">
                    <select name="projectType" class="form-control m-b" th:with="type=${@dict.getType('sys_project_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">开始时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="beginTime" id="datetimeStart" class="form-control" placeholder="yyyy-MM-dd" type="text">
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">结束时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="endTime" id="datetimeEnd" class="form-control" placeholder="yyyy-MM-dd" type="text">
                    </div>
                </div>
            </div>
            <!--<div class="form-group">
                <label class="col-sm-3 control-label">创建人：</label>
                <div class="col-sm-8">
                    <input name="userId" class="form-control" type="text">
                </div>
            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "system/project"
        $("#form-project-add").validate({
            focusCleanup: true,
            rules:{
                projectName:"required"
            },
            messages:{
                projectName:"请输入项目名称"
            }
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-project-add').serialize());
            }
        }
        $('#datetimeStart').datetimepicker({
            language:  'zh-CN',
            format:'yyyy-mm-dd',
            minView:"month",
            autoclose: true
        }).on("changeDate",function(ev){  //值改变事件
            //选择的日期不能大于第二个日期控件的日期
            if(ev.date){
                $("#datetimeEnd").datetimepicker('setStartDate', new Date(ev.date.valueOf()));
            }else{
                $("#datetimeEnd").datetimepicker('setStartDate',null);
            }
        });
        $('#datetimeEnd').datetimepicker({
            language:  'zh-CN',
            format:'yyyy-mm-dd',
            minView:"month",
            autoclose: true
        }).on("changeDate",function(ev){
            //选择的日期不能小于第一个日期控件的日期
            if(ev.date){
                $("#datetimeStart").datetimepicker('setEndDate', new Date(ev.date.valueOf()));
            }else{
                $("#datetimeStart").datetimepicker('setEndDate',new Date());
            }
        });

    </script>
</body>
</html>